// 获取圈子信息
import {$request} from '../../utils/request'
// 获取单个圈子信息
export const getCircleDetail = ((id) => {
    return new Promise ((resolve, reject) => {
        $request({
            url:'circledetail?id='+id,
            method:'GET'
        }).then((res) => {
            console.log("获取圈子信息成功",res);
            resolve(res)
        }).catch((err) => {
            console.log("获取圈子信息失败",err);
            reject(err)
        })
    })
})


// 获取成员状态信息
export const getCircleMember = ((id) => {
    return new Promise ((resolve, reject) => {
        $request({
            url:'circlemember?id='+id,
            method:'GET'
        }).then((res) => {
            console.log("获取圈子成员信息成功",res);
            resolve(res)
        }).catch((err) => {
            console.log("获取圈子成员信息失败",err);
            reject(err)
        })
    })
})

// 申请加入圈子
export const getApplyCircle = ((id) => {
    return new Promise ((resolve, reject) => {
        $request({
            url:'applycircle?id='+id,
            method:'GET'
        }).then((res) => {
            console.log("申请加入圈子息成功",res);
            resolve(res)
        }).catch((err) => {
            console.log("申请加入圈子失败",err);
            reject(err)
        })
    })
})

// 退出圈子
export const getQuitCircle = ((id) => {
    return new Promise ((resolve, reject) => {
        $request({
            url:'quitcircle?id='+id,
            method:'GET'
        }).then((res) => {
            console.log("申请退出圈子息成功",res);
            resolve(res)
        }).catch((err) => {
            console.log("申请退出圈子失败",err);
            reject(err)
        })
    })
})


// 请求帖子数据列表
export const getPost = ((page,circleid) => {
    return new Promise((resolve, reject) => {
        $request({
            url: 'circlegetpost?page=' + page + '&circleid=' + circleid,
            method: 'GET',
        }).then((res) => {
            console.log("apis界面的请求帖子请求发送成功", res);
            resolve(res)
        }).catch((err) => {
            console.log("apis界面的请求帖子请求发送失败", err);
            reject(err)
        })
    })

})


// 删除帖子
export const deletePost = ((id,circleid) => {
    return new Promise((resolve, reject) => {
        $request({
            url: 'circlepostdelete?id=' + id + '&master=' + circleid,
            method: 'GET',
        }).then((res) => {
            console.log("删除帖子请求发送成功", res);
            resolve(res)
        }).catch((err) => {
            console.log("删除帖子请求发送失败", err);
            reject(err)
        })
    })

})
